package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.NcProductStaCost;
import com.lxmes.business.service.INcProductStaCostService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 产品工位成本Controller
 * 
 * @author ruoyi
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/business/ncProductStaCost")
public class NcProductStaCostController extends BaseController
{
    @Autowired
    private INcProductStaCostService ncProductStaCostService;

    /**
     * 查询产品工位成本列表
     */
    @PreAuthorize("@ss.hasPermi('business:ncProductStaCost:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcProductStaCost ncProductStaCost)
    {
        startPage();
        List<NcProductStaCost> list = ncProductStaCostService.selectNcProductStaCostList(ncProductStaCost);
        return getDataTable(list);
    }

    /**
     * 导出产品工位成本列表
     */
    @PreAuthorize("@ss.hasPermi('business:ncProductStaCost:export')")
    @Log(title = "产品工位成本", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcProductStaCost ncProductStaCost)
    {
        List<NcProductStaCost> list = ncProductStaCostService.selectNcProductStaCostList(ncProductStaCost);
        ExcelUtil<NcProductStaCost> util = new ExcelUtil<NcProductStaCost>(NcProductStaCost.class);
        util.exportExcel(response, list, "产品工位成本数据");
    }

    /**
     * 获取产品工位成本详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:ncProductStaCost:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncProductStaCostService.selectNcProductStaCostById(id));
    }

    /**
     * 新增产品工位成本
     */
    @PreAuthorize("@ss.hasPermi('business:ncProductStaCost:add')")
    @Log(title = "产品工位成本", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcProductStaCost ncProductStaCost)
    {
        return toAjax(ncProductStaCostService.insertNcProductStaCost(ncProductStaCost));
    }

    /**
     * 修改产品工位成本
     */
    @PreAuthorize("@ss.hasPermi('business:ncProductStaCost:edit')")
    @Log(title = "产品工位成本", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcProductStaCost ncProductStaCost)
    {
        return toAjax(ncProductStaCostService.updateNcProductStaCost(ncProductStaCost));
    }

    /**
     * 删除产品工位成本
     */
    @PreAuthorize("@ss.hasPermi('business:ncProductStaCost:remove')")
    @Log(title = "产品工位成本", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncProductStaCostService.deleteNcProductStaCostByIds(ids));
    }
}
